home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1999 October
/
Software of the Month - Ultimate Collection Shareware 266.iso
/
pc
/
Xtras
/
Animation Wizard.dir
/
00008_Script_Banners
< prev
next >
Wrap
Text File
|
1997-05-10
|
10KB
|
345 lines
-- Banners script
property ioFieldList
property iFieldFocus
property ioFieldFocus
property iCurrentMotionStyleIndex
property iCurrentVisualStyleIndex
-- The motion styles are:
property ikMotionRightToLeft -- 1
property ikMotionLeftToRight -- 2
property ikMotionUp -- 3
property ikMotionDown --4
property iFirstTIme
property iSaveSeconds
property iSaveFPS
property iSaveBaseline
property iSaveDelayEnter
property iSaveMark
property iSaveCycles
on birth me
global goBannersText
global goSeconds
global goFPS
global goBaseLine
global goDelayEnter
global goCycles
set ioFieldList = [goBannersText, goSeconds, goFPS, goBaseLine, goDelayEnter, goCycles]
set ikMotionRightToLeft = 1
set ikMotionLeftToRight = 2
set ikMotionUp = 3
set ikMotionDown = 4
set iCurrentMotionStyleIndex = ikMotionRightToLeft
set iCurrentVisualStyleIndex = 1
set iFieldFocus = 1
set iFirstTime = TRUE
return me
end birth
on mInit me
global goSeconds
global goFPS
global goBaseLine
global goDelayEnter
global goCycles
global goBanners
global goMarkFrame
global goVisualStyles
global goMotionStyles
global goScoreMgr
-- CheckMark parameter: channel
mInit(goMarkFrame, 4) -- channel
if iFirstTime then -- use intellegent defaults
mSetValue(goSeconds, 5)
mSetValue(goFPS, 5)
set defaultBaseLine = integer(mGetStageHeight(goScoreMgr) / 2)
mSetValue(goBaseLine, defaultBaseLine)
mSetValue(goDelayEnter, 0)
mSetValue(goCycles, 1)
mSetValue(goMarkFrame, TRUE)
set iFirstTime = FALSE
else -- use values saved from when we last left
mSetValue(goSeconds, iSaveSeconds)
mSetValue(goFPS, iSaveFPS)
mSetValue(goBaseLine, iSaveBaseline)
mSetValue(goDelayEnter, iSaveDelayEnter)
mSetValue(goCycles, iSaveCycles)
mSetValue(goMarkFrame, iSaveMark)
end if
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
-- RadioButtons parameters: channel, nChannels, rightAnswer, default
set goMotionStyles = 0
set goMotionStyles = birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
-- VisualStyles Params: castNum, default, nItems, channel
if the machineType < 256 then
mInit(goVisualStyles, the number of cast "BannersVisualStylesMac", ¼
iCurrentVisualStyleIndex, 8, 19)
else
mInit(goVisualStyles, the number of cast "BannersVisualStylesPC", ¼
iCurrentVisualStyleIndex, 8, 19)
end if
-- For keystroke validity checking
set the keydownscript = "mCheckKey(goBanners)"
end mInit
on mSetFieldFocus me, oWhom
set where = getOne(ioFieldList, oWhom)
if where = 0 then
alert("Internal error - mSetFieldFocus could not find object")
return
end if
set iFieldFocus = where
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
end mSetFieldFocus
on mCheckKey me
if the Key = TAB then -- change focus to the next field
set iFieldFocus = IncrMod(iFieldFocus, count(ioFieldList))
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
pass -- pass the event so the hilight goes to the next field
else
if iFieldFocus = 1 then -- the text entry field, allow anything
pass
else -- numeric fields, only allow digits
if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
pass
else
dontPassEvent -- restrict only to digits.
end if
end if
end if
end mCheckKey
on mSetNewMotionStyle me, theNewStyleIndex
set iCurrentMotionStyleIndex = theNewStyleIndex
end mSetNewMotionStyle
on mSetNewVisualStyle me, theNewStyleIndex
set iCurrentVisualStyleIndex = theNewStyleIndex
end mSetNewVisualStyle
on mValidate me
-- Attempt to validate the last field of focus
set lastFieldOKFlag = mValidate(ioFIeldFocus)
return lastFieldOKFlag
end mValidate
on mCreate me
global goMarkFrame
global goMotionStyles
global goVisualStyles
global goScoreMgr
global goCastMgr
global gDevelopmentFlag
global gCastNumTextAsBitmap
global goPlatform
if not(mValidate(me)) then
return
end if
if field("BannersText") = EMPTY then
alert("Please enter some text for the banner.")
return
end if
tell the stage
set theStageFrame = the frame
end tell
set castNumVisualStyle = mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
set theVisualStyleName = the name of cast castNumVisualStyle
set theFont = word 2 of theVisualStyleName
set theSize = word 3 of theVisualStyleName
set theSeconds = integer(field "Seconds")
set fps = integer(field "FPS")
set nFrames = integer(theSeconds * fps)
set baseLine = integer(field "BaseLine")
set delayEnter = integer(field "DelayEnter")
set nCycles = integer(field "Cycles")
set markFirst = mGetValue(goMarkFrame)
-- Call the ScoreMgr to set up the score, # of frames, and 1 channel
-- set nTotalFrames = (delayEnter + nFrames) * nCycles
set nTotalFrames = nFrames * nCycles
if not(mInit(goScoreMgr, nTotalFrames, 1)) then
return
end if
set theCh = mGetNextSelectedChannel(goScoreMgr)
set theFrameNum = mGetStartFrame(goScoreMgr)
set castNumSource = mModifyRichTextCM(goCastMgr, ¼
the text of field "BannersText", theFont, theSize)
if castNumSource = 0 then -- error
return
end if
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumSource
set widthOfTextAsBitmap = the width of member gCastNumTextAsBitmap
set heightOfTextAsBitmap = the height of member castNumSource / ¼
the number of lines in (the text of member castNumSource)
-- Do specific calculations depending on motion style
if (iCurrentMotionStyleIndex = ikMotionRightToLeft) or ¼
(iCurrentMotionStyleIndex = ikMotionLeftToRight) then
set yStart = baseline
set yEnd = baseLine
set yInc = 0
if (iCurrentMotionStyleIndex = ikMotionRightToLeft) then
set xStart = mGetStageRight(goScoreMgr) + 10
set xEnd = 0 - widthOfTextAsBitmap - 10
set xInc = float( xEnd - xStart ) / float(nFrames)
else -- Left to right
set xStart = 0 - widthOfTextAsBitmap - 10
set xEnd = mGetStageRight(goScoreMgr) + 10
set xInc = float( xEnd - xStart ) / float(nFrames)
end if
else -- up or down
set xStart = (mGetStageWidth(goScoreMgr) / 2) - (widthOfTextAsBitmap / 2)
set xEnd = xStart
set xInc = 0
if (iCurrentMotionStyleIndex = ikMotionUp) then
set yStart = mGetStageHeight(goScoreMgr) + heightOfTextAsBitmap + 1
set yEnd = 0 - heightOfTextAsBitmap - 10
set yInc = float( yEnd - yStart ) / float(nFrames)
else -- Down
set yStart = 0 - heightOfTextAsBitmap - 10
set yEnd = mGetStageHeight(goScoreMgr) + heightOfTextAsBitmap + 10
set yInc = float( yEnd - yStart ) / float(nFrames)
end if
end if
set theForeColor = 255
set theBackColor = 0
-- Copy the cast member into the source movie's cast
set castNumTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumSource
tell the stage
pasteClipboardInto member castNumTarget
set the name of member castNumTarget = "RichText" && string(the ticks)
end tell
-- Finally we are ready to generate frames
-- initialize list of frames to record in
set frameList = []
repeat with i = theFrameNum to (theFrameNum + nTotalFrames - 1)
add(frameList, [i])
end repeat
-- Mark first frame upon request
if markFirst then
set firstFrame= getAt(frameList, 1)
set theLabel = "AW.Banner." & word 1 of the text of field "BannersText" & " " & ¼
mGetGeneratedScoreSelection(goScoreMgr)
add(firstFrame, [#label, theLabel])
setAt(frameList, 1, firstFrame)
end if
set relFrameCount = 1
-- Generate the score fragment
repeat with thisCycle = 1 to nCycles
set firstFrame = getAt( frameList, relFrameCount)
set secondFrame = getAt( frameList, relFrameCount + 1)
if delayEnter > 0 then
add(firstFrame, [#tempo, -delayEnter])
add(secondFrame, [#tempo, fps])
else
add(firstFrame, [#tempo, fps])
add(secondFrame, [#tempo, 0])
end if
setAt(frameList, relFrameCount, firstFrame)
setAt(frameList,relFrameCount + 1, secondFrame)
set xLoc = xStart
set yLoc = yStart
repeat with thisFrame = 1 to nFrames
set xLoc = integer(xLoc + .49)
set yLoc = integer(yLoc + .49)
set currentFrame = getAt(frameList,relFrameCount)
add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, 0, 0 ])
-- mWriteSpriteRange(goScoreMgr, theFrameNum, theCh, castNumTarget, ¼
-- theForeColor, theBackColor, xLoc, yLoc, 0, 0)
setAt(frameList, relFrameCount, currentFrame)
set theFrameNum = theFrameNum + 1
set relFrameCount = relFrameCount + 1
set xLoc = xLoc + xInc
set yLoc = yLoc + yInc
end repeat -- thisFrame
end repeat -- thisCycle
mWriteFrame(goScoreMgr, frameList)
set labelName = "Banners" & goPlatform
go label(labelName) + 2 -- to display reselect button
if not(gDevelopmentFlag) then
tell the stage
go frame theStageFrame
end tell
end if
mClean(goScoreMgr)
end mCreate
on mCleanup me
global goMotionStyles
global goSeconds
global goFPS
global goBaseLine
global goDelayEnter
global goCycles
global goMarkFrame
mCleanup(goMotionStyles)
set iSaveSeconds = mGetValue(goSeconds)
set iSaveFPS = mGetValue(goFPS)
set iSaveBaseLine = mGetValue(goBaseLine)
set iSaveDelayEnter = mGetValue(goDelayEnter)
set iSaveCycles = mGetValue(goCycles)
set iSaveMark = mGetValue(goMarkFrame)
mCleanup(goMarkFrame)
end mCleanup